﻿using System;
using System.Runtime.Serialization;
using System.ServiceModel;
using Navigant.Common;

namespace Navigant.DataContracts
{
    [DataContract(Name = "PreservationNoticeContract", Namespace = ServiceConstants.DataContractNamespace)]
    [ServiceKnownType(typeof(CaseChildItemContract))]
    public class PreservationNoticeContract : CaseChildItemContract
    {
        #region Constants

        private static class Constants
        {
            public const string TemplateDisplayUriFormatString = "{0}/_layouts/NavigantPages/PreservationNoticeView.aspx?noticeId={1}";
            public const string CustodianDisplayUriFormatString = "{0}/Lists/Custodians/DispForm.aspx?ID={1}";
        }

        #endregion

        #region Properties

        [DataMember]
        public int TemplateId { get; set; }
        [DataMember]
        public string TemplateName { get; set; }
        [DataMember]
        public string TemplateSubject { get; set; }
        [DataMember]
        public string Status { get; set; }
        [DataMember]
        public int CustodianId { get; set; }
        [DataMember]
        public string CustodianName { get; set; }
        [DataMember]
        public string CustodianEmail { get; set; }
        [DataMember]
        public string FromAddress { get; set; }
        [DataMember]
        public DateTime DateMessageCreated { get; set; }
        [DataMember]
        public DateTime? DateMessageSent { get; set; }
        [DataMember]
        public DateTime? DateMessageAcknowledged { get; set; }

        public Uri TemplateDisplayUri
        {
            get
            {
                return new Uri(string.Format(Constants.TemplateDisplayUriFormatString,
                    this.ParentCase.Url, this.TemplateId));
            }
        }

        public Uri CustodianDisplayUri
        {
            get
            {                
                return new Uri(string.Format(Constants.CustodianDisplayUriFormatString, 
                    this.ParentCase.Url, this.CustodianId));                 
            }
        }

        #endregion
    }
}
